package com.hxzy.controller.vue.dictdata;

import com.hxzy.common.resp.R;
import com.hxzy.common.util.DictDataCacheUtil;
import com.hxzy.controller.vue.dictdata.resp.SysDictDataResp;
import com.hxzy.service.SysDictDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author wy
 * @Description TODO
 * @Date 2023/9/4 9:14
 * @Version 1.0
 */
@RequestMapping(value = "/api/dictdata")
@RestController
@Api(tags = "后台-数据字典明细")
public class SysDictDataController {

    /**
     * 数据字典数据库
     */
    @Autowired
    private SysDictDataService sysDictDataService;

    /**
     * 数据字典缓存
     */
    @Autowired
    private DictDataCacheUtil  dictDataCacheUtil;

    @ApiOperation(value = "根据dictType去缓存中查询值")
    @GetMapping(value = "/bytype/{dictType}")
    public R<List<SysDictDataResp>>  findByDictType(@PathVariable(value = "dictType") String dictType){
        List<SysDictDataResp> byDictType = this.dictDataCacheUtil.findByDictType(dictType);
        return R.okHasData(byDictType);
    }

}
